package com.lg.baselibrary.activity;

import android.support.v4.app.Fragment;
import android.view.View;

import com.lg.baselibrary.R;
import com.lg.baselibrary.widget.BottomTabView;
import com.lg.baselibrary.widget.TabItemView;

import java.util.List;

/**
 * Created by LiGang on 2017/5/29.
 * 用于底部Tabs + FrameLayout + Fragment 的app界面主架构
 * 支持底部tabs中间有个突出的CenterView，需要手动重写setCenterView()方法，在方法里调用
 * View setCenterView(int centerViewLayout, View.OnClickListener clickListener)
 */

abstract class BaseBottomTabActivity extends BaseActivity {
    protected View centerView;
    protected List<Fragment> fragments;
    protected BottomTabView bottomTabView;

    @Override
    protected void initView() {
        bottomTabView = findView(R.id.bottomTabView);
        setCenterView();
        fragments = getFragments();
    }

    protected abstract List<TabItemView> getTabViews();
    protected abstract List<Fragment> getFragments();

    /**
     * 需要设置CenterView的话，就重写该方法
     */
    protected void setCenterView(){

    }
    protected final View setCenterView(int centerViewLayout, View.OnClickListener clickListener){
        View centerView = getLayoutInflater().inflate(centerViewLayout,bottomTabView,false);
        if(clickListener != null){
            centerView.setOnClickListener(clickListener);
        }
        return this.centerView = centerView;
    }
    protected View getCenterView(){
        return this.centerView;
    }

    /**
     * 显示tab标签上tip消息的数量
     * @param tabIndex
     * @param tipCount
     */
    protected void showTipCount(int tabIndex, int tipCount){
        bottomTabView.showTipCount(tabIndex,tipCount);
    }

    /**
     * 隐藏tab标签上的tip消息
     * @param tabIndex
     */
    protected void hideTipCount(int tabIndex){
        bottomTabView.hideTipCount(tabIndex);
    }

    /**
     * 显示tab标签上的tip提示图片
     * @param tabIndex
     * @param tipImgResId tip提示图片资源id
     */
    protected void showTipImageView(int tabIndex, int tipImgResId){
        bottomTabView.showTipImageView(tabIndex,tipImgResId);
    }
    protected void showTipImageView(int tabIndex, int tipImgResId,int topMargindp,int rightMargindp){
        bottomTabView.showTipImageView(tabIndex,tipImgResId,topMargindp,rightMargindp);
    }
    protected void showTipImageView(int tabIndex, int tipImgResId,int topMargindip,int rightMargindip,int widthdip,int heighdip){
        bottomTabView.showTipImageView(tabIndex,tipImgResId,topMargindip,rightMargindip,widthdip,heighdip);
    }
    /**
     * 隐藏tab标签上的tip提示图片
     * @param tabIndex
     */
    protected void hideTipImageView(int tabIndex){
        bottomTabView.hideTipImageView(tabIndex);
    }

}
